package com.ltmall.api.controller;

import com.ltmall.api.bean.News;
import com.ltmall.api.manager.NewsManager;
import com.ltmall.api.util.PageUtil;
import com.ltmall.api.util.RemoteUtil;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class NewsController {
    private NewsManager newsManager;

    public NewsManager getNewsManager() {
        return newsManager;
    }

    public void setNewsManager(NewsManager newsManager) {
        this.newsManager = newsManager;
    }

    //获取消息列表
    public void newsList(HttpServletRequest request, HttpServletResponse response) {
        String typeA = request.getParameter("type");
        String cPage = request.getParameter("page");
        String userID = request.getParameter("userID");

        PageUtil page = new PageUtil(Integer.parseInt(cPage));

        List<News> newsList = newsManager.newsList(Integer.parseInt(userID), page, Integer.parseInt(typeA));
        RemoteUtil.response(response, newsList, 1, "返回成功");
    }

}
